#ifndef __LOG_MANAGER_H__
#define __LOG_MANAGER_H__

#include <set>
#include <queue>
#include <string>
#include <fstream>
#include <sstream>

class LogManager
{
public:
    LogManager();
    virtual ~LogManager();
    int MainLoop();

private:
    int EnvReady(const std::string& srvName);
    int UpdateSuffixOfAllFiles();
    int RotateLogsIfNecessary(uint32_t logDataSize);
    int WriteToLogFile(const std::string& logData);
    std::set<std::string> GetSortedLogFiles(const std::string& path, const std::string& fileName);

private:
    bool            mRunning;
    uint32_t        mMaxFileSize;
    std::string     mBaseLogFile;
    std::string     mLogsDirPath;
    std::string     mCurrentLogFile;
    std::ofstream   mLogFileStream;
    std::set<std::string> mLogFilePaths;
};

#endif // __LOG_MANAGER_H__
